package sendOAUtils;

import nc.bs.framework.common.RuntimeEnv;
import org.w3c.dom.Document;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File;

/**
 * uil
 */
public class GetUrlConfig {
    public static String get(String key) {
        String str="";
        try {
            File xmlFile = new File(file());
            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
            Document doc = dBuilder.parse(xmlFile);
            doc.getDocumentElement().normalize();
            str = doc.getElementsByTagName(key).item(0).getTextContent();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return str;

    }

    private static String file() {
        return RuntimeEnv.getInstance().getNCHome() + "/resources/config/oa/File.xml";
    }
}
